﻿<Window x:Class="MsgBoxSamples.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:params="clr-namespace:MsgBoxSamples.ViewModel"
        xmlns:conv="clr-namespace:MsgBox.Converter;assembly=MsgBox"
        
        Title="WPF MessageBox sample"
        SizeToContent="WidthAndHeight"
        WindowStyle="SingleBorderWindow"

        xmlns:SampleConv="clr-namespace:MsgBoxSamples.Converter"

        Name="SamplesMainWindow"
        >
  <Window.Resources>
    <SampleConv:SampleParametersConverter x:Key="sampleParametersConverter" />
  </Window.Resources>
    <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
      <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <TabControl>
      <TabItem Header="Custom Tests">
        <StackPanel Grid.Column="1" Grid.RowSpan="2" Margin="3">
          <TextBlock TextWrapping="Wrap">
            Use this part of the sample application to construct sample message
            boxes with the given parameters listed below.
          </TextBlock>
          <TextBlock TextWrapping="Wrap" Margin="0,12">
        <Run>Click the 'Show Test Message' button to display the actual message.
        </Run>
          </TextBlock>

          <StackPanel Orientation="Horizontal">
            <GroupBox Header="Message Box Image">
              <StackPanel Orientation="Horizontal" >
                <StackPanel>
                  <ComboBox ItemsSource="{Binding MessageImages}"
                      SelectedItem="{Binding MessageImageSelected}"
                      SelectedValuePath="Name"
                      DisplayMemberPath="Name"
                      HorizontalAlignment="Left" VerticalAlignment="Top"
                      MinWidth="150" Margin="3" />

                  <Image Source="{Binding MessageImageSelected.EnumKey, Converter={conv:ImageEnumToImageConverter}, Mode=OneWay}"
                  HorizontalAlignment="Left"
                  VerticalAlignment="Center" 
                  Height="48" Width="48" Margin="9"
                  Grid.Column="0" Grid.Row="0" />
                </StackPanel>
              </StackPanel>
            </GroupBox>

            <GroupBox Header="MessageBox Style:">
              <StackPanel>
                <ComboBox ItemsSource="{Binding MessageBoxStyles}"
                    SelectedItem="{Binding MessageBoxStyleSelected}"
                    SelectedValuePath="Name"
                    DisplayMemberPath="Name"
                    HorizontalAlignment="Left" VerticalAlignment="Top"
                    MinWidth="150" Margin="3" />
                <StackPanel>
                  <TextBlock TextWrapping="Wrap" Margin="3">
Tip: The message box implementation supports native windows chrome<LineBreak/>
styled message boxes and custom styled message boxes. Use this<LineBreak/>
property to test the build in styles (both native and custom).
                  </TextBlock>
                </StackPanel>
              </StackPanel>
            </GroupBox>
          </StackPanel>

          <StackPanel Orientation="Horizontal">
            <GroupBox Header="Message Text and Caption">
              <StackPanel>
                <StackPanel>
                  <Label Content="Caption Text:" />
                  <TextBox Text="{Binding CaptionText}" />
                </StackPanel>
                <StackPanel>
                  <Label Content="Message Text:" />
                  <TextBox Text="{Binding MessageText}" />
                </StackPanel>
              </StackPanel>
            </GroupBox>

            <CheckBox Content="Show Copy Button" IsChecked="{Binding ShowCopyButton}" Margin="3" />
          </StackPanel>

          <StackPanel Orientation="Horizontal">
            <StackPanel>
              <Label Content="Buttons available in Message Box:" />
              <ComboBox ItemsSource="{Binding MessageButtons}"
                      SelectedItem="{Binding MessageButtonSelected}"
                      SelectedValuePath="Name"
                      DisplayMemberPath="Name"
                      HorizontalAlignment="Left" VerticalAlignment="Top"
                      MinWidth="150" Margin="3" />
            </StackPanel>

            <StackPanel Margin="12,0">
              <Label Content="Default Button:" />
              <ComboBox ItemsSource="{Binding DefaultMessageButtons}"
                      SelectedItem="{Binding DefaultMessageButtonSelected}"
                      SelectedValuePath="Name"
                      DisplayMemberPath="Name"
                      HorizontalAlignment="Left" VerticalAlignment="Top"
                      MinWidth="150" Margin="3" />
            </StackPanel>

            <StackPanel Margin="12,0">
              <Label Content="Button Language:" />
              <ComboBox ItemsSource="{Binding ButtonLanguages}"
                    SelectedItem="{Binding ButtonLanguageSelected}"
                    SelectedValuePath="BCP47"
                    DisplayMemberPath="DisplayName"
                    HorizontalAlignment="Left" VerticalAlignment="Top"
                    MinWidth="150" Margin="3" />
            </StackPanel>
          </StackPanel>

          <StackPanel Orientation="Horizontal" Margin="3,21">
            <Button Content="Show _Test Message" IsDefault="True"
                    Command="{Binding TestMsgBoxParameters}" HorizontalAlignment="Left" Margin="3" />

            <StackPanel Orientation="Horizontal" Margin="3,0">
              <Label Content="Result:" />
              <Label Content="{Binding Result}" />
            </StackPanel>
          </StackPanel>
        </StackPanel>
      </TabItem>

      <TabItem Header="Pre-defined Test">
        <StackPanel>
          <StackPanel Margin="10">
          <TextBlock TextWrapping="Wrap">
          The samples on this page demonstrate the usage of the WPF message box. Press <Bold>CNTR-C</Bold>
          to copy the twxt displayed in a message box.
          </TextBlock>
          <TextBlock TextWrapping="Wrap">          
            Click one of the <Bold>Sample buttons</Bold> below to invoke a sample message box.
          </TextBlock>
        </StackPanel>
        <Grid Grid.Row="1" Margin="10">
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
          </Grid.ColumnDefinitions>

          <TextBlock Text="Message box with only message" VerticalAlignment="Center" Margin="3" />
            <Button Height="24" Width="90" Content="Sample 1" Margin="3" 
                    Grid.Row="0" HorizontalAlignment="Left" Grid.Column="1" 
                    VerticalAlignment="Center" Name="Sample1" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample1"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

            <TextBlock Text="Message box with title and message" VerticalAlignment="Center" Margin="3" Grid.Row="1" />
            <Button Height="24" Width="90" Content="Sample 2" Margin="3" Grid.Row="1" 
                  HorizontalAlignment="Left" Grid.Column="1" 
                  VerticalAlignment="Center" Name="Sample2" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample2"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Message box with YES, NO button" VerticalAlignment="Center" Margin="3" Grid.Row="2" />
          <Button Height="24" Width="90" Content="Sample 3" Margin="3" Grid.Row="2" 
                HorizontalAlignment="Left" Grid.Column="1" 
                VerticalAlignment="Center" Name="Sample3" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample3"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Message box with OK Button and details" VerticalAlignment="Center" Margin="3" Grid.Row="3" />
          <Button Height="24" Width="90" Content="Sample 4" Margin="3" Grid.Row="3" 
                HorizontalAlignment="Left" Grid.Column="1" 
                VerticalAlignment="Center" Name="Sample4" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample4"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Message box with Question" VerticalAlignment="Center" Margin="3" Grid.Row="4" />
          <Button Height="24" Width="90" Content="Sample 5" Margin="3" Grid.Row="4" 
                HorizontalAlignment="Left" Grid.Column="1" 
                VerticalAlignment="Center" Name="Sample5" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample5"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Message box with Question and No Default button" VerticalAlignment="Center" Margin="3" Grid.Row="5" />
          <Button Height="24" Width="90" Content="Sample 6" Margin="3" Grid.Row="5" 
                      HorizontalAlignment="Left" Grid.Column="1" 
                      VerticalAlignment="Center" Name="Sample6" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample6"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Message box with Question, No default button, and Hyperlink" VerticalAlignment="Center" Margin="3" Grid.Row="6" />
          <Button Height="24" Width="90" Content="Sample 7" Margin="3" Grid.Row="6" 
                            HorizontalAlignment="Left" Grid.Column="1" 
                            VerticalAlignment="Center" Name="Sample7" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample7"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Message box with Question, No default button, and Custom Hyperlink Navigation"
                       TextWrapping="WrapWithOverflow"
                       VerticalAlignment="Center" Margin="3" Grid.Row="7" />
          <Button Height="24" Width="90" Content="Sample 8" Margin="3" Grid.Row="7" 
                                  HorizontalAlignment="Left" Grid.Column="1" 
                                  VerticalAlignment="Center" Name="Sample8" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample8"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Message box with Question (OK, Cancel) and NO Copy Message button"
                             TextWrapping="WrapWithOverflow"
                             VerticalAlignment="Center" Margin="3" Grid.Row="8" />
          <Button Height="24" Width="90" Content="Sample 9" Margin="3" Grid.Row="8" 
                                        HorizontalAlignment="Left" Grid.Column="1" 
                                        VerticalAlignment="Center"  Name="Sample9" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample9"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Message box with Question and NO Default button"
                                   TextWrapping="WrapWithOverflow"
                                   VerticalAlignment="Center" Margin="3" Grid.Row="9" />
          <Button Height="24" Width="90" Content="Sample 10" Margin="3" Grid.Row="9" 
                  HorizontalAlignment="Left" Grid.Column="1" 
                  VerticalAlignment="Center" Name="Sample10" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample10"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Message box with Question and NO Default button"
                                         TextWrapping="WrapWithOverflow"
                                         VerticalAlignment="Center" Margin="3" Grid.Row="10" />
          <Button Height="24" Width="90" Content="Sample 11" Margin="3" Grid.Row="10" 
                  HorizontalAlignment="Left" Grid.Column="1" 
                  VerticalAlignment="Center" Name="Sample11" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample11"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Working with exceptions"
                       TextWrapping="WrapWithOverflow"
                       VerticalAlignment="Center" Margin="3" Grid.Row="11" />
          <Button Height="24" Width="90" Content="Sample 12" Margin="3" Grid.Row="11" 
                  HorizontalAlignment="Left" Grid.Column="1" 
                  VerticalAlignment="Center" Name="Sample12" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample12"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

          <TextBlock Text="Working with exceptions (labeling problem above message tree)"
                       TextWrapping="WrapWithOverflow"
                       VerticalAlignment="Center" Margin="3" Grid.Row="12" />
          <Button Height="24" Width="90" Content="Sample 13" Margin="3" Grid.Row="12" 
                  HorizontalAlignment="Left" Grid.Column="1" 
                  VerticalAlignment="Center" Name="Sample13" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample13"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

            <TextBlock Text="Display a message box with explicit reference to owning window."
                       TextWrapping="WrapWithOverflow"
                       VerticalAlignment="Center" Margin="3" Grid.Row="13" />
            <Button Height="24" Width="90" Content="Sample 14" Margin="3" Grid.Row="13" 
                    HorizontalAlignment="Left" Grid.Column="1" 
                    VerticalAlignment="Center" Name="Sample14" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample14"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

            <TextBlock Text="Display a message box with a default image."
                       TextWrapping="WrapWithOverflow"
                       VerticalAlignment="Center" Margin="3" Grid.Row="14" />
            <Button Height="24" Width="90" Content="Sample 15" Margin="3" Grid.Row="14" 
                    HorizontalAlignment="Left" Grid.Column="1" 
                    VerticalAlignment="Center" Name="Sample15" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample15"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

            <TextBlock TextWrapping="WrapWithOverflow"
                       VerticalAlignment="Center" Margin="3" Grid.Row="15">
            Display a message box that will not close via<LineBreak/>
            Esc, F4, or Window Close (x) button.
            </TextBlock>
            <Button Height="24" Width="90" Content="Sample 16" Margin="3" Grid.Row="15" 
                    HorizontalAlignment="Left" Grid.Column="1" 
                    VerticalAlignment="Center" Name="Sample16" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample16"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>

            <TextBlock TextWrapping="WrapWithOverflow"
                       VerticalAlignment="Center" Margin="3" Grid.Row="16">
              Display a message box that WILL CLOSE<LineBreak/>
              via Esc, F4, or Window Close (x) button leaving with a No result.
            </TextBlock>
            <Button Height="24" Width="90" Content="Sample 17" Margin="3" Grid.Row="16" 
                    HorizontalAlignment="Left" Grid.Column="1" 
                    VerticalAlignment="Center" Name="Sample17" Command="{Binding TestSamplMsgBox}">
              <Button.CommandParameter>
                <MultiBinding Converter="{StaticResource sampleParametersConverter}">
                  <Binding ElementName="Sample17"/>
                  <Binding ElementName="SamplesMainWindow"/>
                </MultiBinding>
              </Button.CommandParameter>
            </Button>
          </Grid>

        <StackPanel Orientation="Horizontal" Margin="3,0">
          <Label Content="Result:" />
          <Label Content="{Binding Result}" />
        </StackPanel>

        </StackPanel>
      </TabItem>
    </TabControl>
  </Grid>
</Window>
